﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;
using System.ServiceModel.Activation;
using System.Web.Mvc;

namespace JXT.PrimaryKey.Batman.WcfService.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes();
        }

        private static void RegisterRoutes()
        {
            RouteTable.Routes.Add(new ServiceRoute("user",
                new WebServiceHostFactory(), GetServiceType("WcfUserService")));
            RouteTable.Routes.Add(new ServiceRoute("quotation",
                new WebServiceHostFactory(), GetServiceType("WcfQuotationService")));
            RouteTable.Routes.MapRoute("default",
                "{controller}/{action}",
                new { controller = "main", action = "index" });
        }

        private static Type GetServiceType(string typeName)
        {
            string typeFullName = String.Format("JXT.PrimaryKey.Batman.WcfService.Services.{0}, JXT.PrimaryKey.Batman.WcfService.Services", typeName);
            return Type.GetType(typeFullName);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}